package com.yc.boot.train.api;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yc.boot.common.model.response.Outcome;
import com.yc.boot.sys.entity.SysUser;
import com.yc.boot.train.business.CourseManageBussiness;
import com.yc.boot.train.entity.TrainCourse;
import com.yc.boot.train.model.find.CourseCount;
import com.yc.boot.train.model.find.CourseManage;
import com.yc.boot.train.model.find.FindUserByCourse;
import com.yc.boot.train.model.find.IPageCourseManage;
import com.yc.boot.train.model.save.SaveCourseManage;
import com.yc.boot.train.model.save.SaveGradeManage;
import com.yc.boot.train.model.update.UpdateCourse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * Create with IntelliT IDEA
 *
 * @Author: zhengmingzhe
 * @Date: 2022/01/10/13:48
 * @Description:    课程管理界面接口
 */
@RestController
@Api(tags = "课程管理界面接口")
@RequestMapping("/courseManage")
public class CourseManageApi {
    @Resource
    private CourseManageBussiness courseManageBussiness;

    @GetMapping("/queryCourseById")
    @ApiOperation("根据教员ID查询相应课程")
    public Outcome<IPage<TrainCourse>> queryCourseById(IPageCourseManage param){
        return Outcome.success(courseManageBussiness.queryCourseById(param));
    }

    @GetMapping("/queryCourseCount")
    @ApiOperation("统计每门课程的选课人数")
    public Outcome <List<CourseCount>> queryCourseCount(){
        return Outcome.success(courseManageBussiness.queryCourseCount());
    }

    @PostMapping("/saveCourseMessage")
    @ApiOperation("添加课程信息管理项")
    public Outcome saveCourseMessage(@RequestBody @Valid SaveCourseManage param){
        return courseManageBussiness.saveCourseMessage(param);
    }

    @PutMapping("/updateCourseById")
    @ApiOperation("修改课程信息管理项")
    public Outcome updateCourseById(@RequestBody @Valid UpdateCourse course){
        return courseManageBussiness.updateCourseById(course);
    }

    @DeleteMapping("/deleteCourseMessage")
    @ApiOperation("删除")
    public Outcome deleteCourseMessage(@RequestBody @Valid @Size(min = 1) List<Long> id) {
        return Outcome.status(courseManageBussiness.delete(id));
    }


}
